package com.vm.activity;

import java.util.List;
import com.vm.db.UpgradeSoftDao;
import com.vm.model.UpgradeSoft;
import com.vm.myview.ViewUpgradeUtils;
import com.wwtscapp.apk.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * 
 * @ProjectName: [WeiMai]
 * @Author: [kent.wang]
 * @CreateDate: [2015年3月10日 下午5:06:29]
 * @Version: [v1.0]
 * 
 */
public class SoftUpgradeActivity extends Activity {

	List<UpgradeSoft> appList;
	ImageView imgbtn_search_back;
	UpgradeSoftDao dao;
	TextView tv_updated_number;
	ViewUpgradeUtils viewUpgradeUtils;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.software_update);

		viewUpgradeUtils = new ViewUpgradeUtils(this, this);
		dao = new UpgradeSoftDao();
		init();

		appList = dao.getUpgradeSofts();
		// 好啦 这下手机上安装的应用数据都存在appList里了。
		tv_updated_number.setText(Integer.toString(appList.size()));

		LinearLayout found_ll_1 = (LinearLayout) findViewById(R.id.found_ll_1);
		if (appList != null) {
			for (int i = 0; i < appList.size(); i++) {
				found_ll_1.addView(viewUpgradeUtils.dyAddView(i,
						appList.get(i), 1));
			}
		}

	}

	/**
	 * 初始化
	 */
	private void init() {
		tv_updated_number = (TextView) findViewById(R.id.tv_updated_number);

		imgbtn_search_back = (ImageView) findViewById(R.id.imgbtn_search_back);
		imgbtn_search_back.setOnClickListener(btn_backListener);
	}

	/**
	 * imgbtn_search_back 返回按钮监听
	 */
	OnClickListener btn_backListener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			onBackPressed();
		}
	};

	/**
	 * 手机自带返回按钮监听
	 */
	@Override
	public void onBackPressed() {
		super.onBackPressed();
	}
}
